﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace AzMan.WebSite
{
	public partial class _Default : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{

			Response.Write(
				"Application Name: " + Roles.ApplicationName + "<br>");
			// Sample output: Application Name: App1
			Response.Write(
				 "User=" + User.Identity.Name + ", IsUserInRole(\"foo2\")  : " +
				 Roles.IsUserInRole("foo2") + "<br>");
			// Sample output: IsUserInRole("foo2") : True
			Response.Write(
				 "Role foo2 exists:" + Roles.RoleExists("foo2") + "<br>");
			// Sample output: Role foo2 exists:True

			Response.Write(
				 "Role foo3 exists:" + Roles.RoleExists("foo3") + "<br>");
			// Sample output: Role foo3 exists:False
			string[] myroles = Roles.GetAllRoles();
			Response.Write(
				 "No of Application Roles: " + myroles.Length + "<br>");
			// Sample output: No of Application Roles: 4

			for (int i = 0; i < myroles.Length; i++)
			{
				Response.Write("Role: " + myroles[i] + "<br>");
			}
			/*
			Sample output:
			Role: foo
			Role: foo1
			Role: foo2
			Role: foo4
			*/

			Response.Write("<HR><HR>");
			string[] myrolesfu = Roles.GetRolesForUser();
			Response.Write("No of Roles For User : " + myrolesfu.Length + "<br>");
			//Sample output: No of Roles For User : 1

			for (int i = 0; i < myrolesfu.Length; i++)
			{
				Response.Write("Role: " + myrolesfu[i] + "<br>");
				//Sample output: Role: foo2
			}
			Response.Write("<hr />Creating role foo3<br />");
			Roles.CreateRole("foo3");
			Response.Write("Role foo3 exists:" + Roles.RoleExists("foo3") + "<br>");
			//Sample output: Role foo3 exists:True
			Roles.DeleteRole("foo3");
			Response.Write("Role foo3 exists after DeleteRole: " +
			Roles.RoleExists("foo3") + "<br>");
			//Sample output: Role foo3 exists after DeleteRole: False
		}

	}
}
